package sanrenxing.dayEnd.backRepertoryTotal.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sanrenxing.dayEnd.backRepertoryTotal.dao.TATrabsactionDao;
import sanrenxing.dayEnd.backRepertoryTotal.domain.TATrabsactionSettlement;
import sanrenxing.dayEnd.backRepertoryTotal.domain.TATrabsactionSettlementTwo;
import sanrenxing.dayEnd.backRepertoryTotal.service.TATrabsactionBiz;

import java.util.List;

/**
 * 功能:ta交易结算业务层实现类
 * 编写者：
 * 日期：2021
 * 版本：1.0
 */
@Service("TATrabsactionBiz")
public class TATrabsactionBizImpl implements TATrabsactionBiz {
    @Autowired
    private TATrabsactionDao taTrabsactionDao=null;

    /**
     * 分页查询条件
     *
     * @param rows
     * @param pages
     * @param condition
     * @return
     */
    @Override
    public List<TATrabsactionSettlementTwo> findByPages(int rows, int pages, String condition) {
        int start=(pages-1)*rows;
        return taTrabsactionDao.findByPage(start,rows,condition);
    }

    /**
     * 按条件统计记录数
     *
     * @param condition 统计条件
     * @return 条件
     */
    @Override
    public int count(String condition) {
        return taTrabsactionDao.count(condition);
    }

    /**
     * 获取查询条件
     *
     * @param taTrabsactionSettlement
     * @return 条件字符串
     */
    @Override
    public String getCount(TATrabsactionSettlement taTrabsactionSettlement) {
        //定义空字符串
        String condition="";
        //如果TA交易结算为空
        if(taTrabsactionSettlement==null){
            return condition;
        }
        //如果类型不为空
        if(taTrabsactionSettlement.getTranType()!=0){
            condition+="and tranType="+taTrabsactionSettlement.getTranType();
        }
        //如果状态不为空
        if(taTrabsactionSettlement.getTranStatus()!=0){
            condition+="and tranStatus="+taTrabsactionSettlement.getTranStatus();
        }
        return condition;
    }

    /**
     * 根据Ta交易编号删除数据
     *
     * @param dataId Ta交易编号
     * @return 1：删除成功；0：删除失败
     */
    @Override
    public int delete(int dataId) {
        return taTrabsactionDao.delete(dataId);
    }

    /**
     * 修改ta交易结算数据
     *
     * @param taTrabsactionSettlement ta交易结算数据对象
     * @return 1：修改成功；0：修改失败
     */
    @Override
    public int update(TATrabsactionSettlement taTrabsactionSettlement) {
        return taTrabsactionDao.update(taTrabsactionSettlement);
    }

    /**
     * 查询所有ta交易处理数据
     *
     * @return ta交易处理数据对象集合
     */
    @Override
    public TATrabsactionSettlement findById(int dataId) {
        return taTrabsactionDao.findById(dataId);
    }

    /**
     * 调用成立基金产生的ta数据
     * @return
     */
    @Override
    public TATrabsactionSettlementTwo fundSetupData() {
        return taTrabsactionDao.fundSetupData();
    }

    @Override
    public TATrabsactionSettlement addFundSetup() {
        return taTrabsactionDao.addFundSetup();
    }

    @Override
    public void updateFundSetup() {
        taTrabsactionDao.updateFundSetup();
    }
}
